package com.gexada.simplechat.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration;

/**
 * 连接到 {@code Redis} 服务
 * 并初始化 {@link RedisHttpSessionConfiguration} 服务
 */
@Configuration
@EnableRedisHttpSession
public class RedisConfig {

	@Bean
	public JedisConnectionFactory connectionFactory(RedisConnectionProperties conn) throws Exception {
		JedisConnectionFactory factory = new JedisConnectionFactory();
		factory.setPort(conn.getPort());
		return factory;
	}
}
